﻿using ConfigCreate.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConfigCreate.Model
{
    internal class VisibilityPanel
    {
        private List<CreateControlBasePanel> Panels = new List<CreateControlBasePanel>();
        private List<object> Values = new List<object>();
        private bool IsReversal = true;

        public VisibilityPanel(CreateControlBasePanel panel, object value, bool is_reversal)
        {
            Panels.Add(panel);
            Values.Add(value);
            IsReversal = is_reversal;
        }

        public void AddPanelAndValue(CreateControlBasePanel panel, object value, bool is_reversal)
        {
            Panels.Add(panel);
            Values.Add(value);
            IsReversal= is_reversal;
        }

        public bool CheckVisibility()
        {
            bool flag = IsVisible();
            if (IsReversal)
                return !flag;
            return flag;
        }

        private bool IsVisible()
        {
            for (int i = 0; i < Panels.Count; i++)
            {
                if (Panels[i].CheckValue(Values[i]))
                    return true;
            }
            return false;
        }
    }
}
